package com.wisdytech.linkdcs.linkdcsservicepad.pad.action;

import com.wisdytech.common.bean.StandardResult;
import com.wisdytech.linkdcs.linkdcsservicepad.common.BaseUtils;
import com.wisdytech.linkdcs.linkdcsservicepad.pad.service.ISystemService;
import com.wisdytech.linkdcs.system.model.SysUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

/**
 * 用户登录相关
 * @author chenbin
 *
 */
@RestController()
@RequestMapping("/app/system")
public class SystemAction {
	
	@Resource
	ISystemService systeService;
	
	private Logger logger =LoggerFactory.getLogger(getClass());
	
	
	@RequestMapping("/userLogin")
	public StandardResult userLogin(String username , String password, HttpServletRequest request) {
		
		boolean loginResult =systeService.login(username, password);
		if(!loginResult) {
			logger.error("登陆账号密码错误！  账号为：{}，密码为：{}",username,password);
			return StandardResult.getFailResult("登陆失败");
		}
		List<String> resources= systeService.getUserResource(username);
		Map<String,Object> result = BaseUtils.getRetResult("resouceList", resources);
		
		return StandardResult.getSuccessResult(result);
	}
	
//	@RequestMapping("/getCheckUserList")
//	public StandardResult getCheckUserList() {
//		List<SysUser> users =systeService.getUsers();
//		List<CheckUserDto> checkUsers =PojoConvertUtil.convertPojos(users, CheckUserDto.class);
//		Map<String,Object> result =BaseUtils.getRetResult("listData",checkUsers);
//		return StandardResult.getSuccessResult(result);
//	}

	
	
}
